package com.haust.search.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "item", shards = 1, replicas = 0)
public class SearchItem implements Serializable {
    /**
     * @Id 注解 -主键 对应ES中的元数据 _id
     * @Field 注解 对应ES的元数据 _source 中的某个字段
     */
    @Id
    @Field(name = "id", type = FieldType.Keyword)
    private Long id; //商品主键

    @Field(name = "title", type = FieldType.Text, analyzer = "ik_max_word")
    private String title;  //商品标题

    @Field(name = "sellPoint", type = FieldType.Text, analyzer = "ik_smart")
    private String sellPoint; //买点

    @Field(name = "price", type = FieldType.Long)
    private Long price;

    @Field(name = "image", type = FieldType.Keyword, index = false)
    private String image;

    @Field(name = "categoryName", type = FieldType.Text, analyzer = "ik_smart")
    private String categoryName;

    @Field(name = "itemDesc", type = FieldType.Text, analyzer = "ik_smart")
    private String itemDesc;

    @Field(name = "updated", type = FieldType.Date, format = DateFormat.basic_date_time)
    private Date updated;
}
